home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / pkpas1.zip / PKWAREU.INC < prev    next >
Text File  |  1993-10-17  |  6KB  |  152 lines

  1. {$D-,S+,R-,B-}
  2. UNIT PKWAREU;
  3. {$Define ShareWare}  { To Define public version }
  4. (*************************************************************************
  5.                   PKWare unit for Turbo Pascal. ver 1.0
  6.  
  7.                        Compiled: Oct. 17,1993.
  8.  
  9.                     Copyright (c) Terry Sansom 1993.
  10.  
  11.   The terms PKZip and Pkunzip are known to be trademarks or service marks
  12.    of PKWARE Inc.  As such this program/unit no way hinders their right
  13.    to such marks.
  14.  
  15.   Author makes no express warranty for this product, and is not liable
  16.   for any damages cause by the the use of, or inability to use, this product.
  17.  
  18.   If you would like the source code to this unit please contact me. I
  19.   charge a small fee for my time, and do not want the code released to the
  20.   public domain. I can be reached at.
  21.  
  22.     Terry Sansom,
  23.     9102 83 Ave
  24.     Edmonton, Alberta
  25.     CANADA
  26.     T6C 1B7
  27.  
  28.    Or on Compuserve  [70574,3205]
  29.  
  30.  *************************************************************************)
  31.  
  32. (**) INTERFACE (**)
  33.  
  34. Uses DOS;
  35.  
  36. Const
  37.         CentralFileHeaderSignature    = $02014b50; { As defined by PKWARE }
  38.         CentralFileHeaderEndSignature = $06054b50;
  39.  
  40.         { Change as desired, for ease of use only. See demo }
  41.         CompMethod : Array[0..8] of string[12] =
  42.                         ('stored',
  43.                          'shrunk',
  44.                          'compressed 1',
  45.                          'compressed 2',
  46.                          'compressed 3',
  47.                          'compressed 4',
  48.                          'imploded',
  49.                          'tokenized',
  50.                          'deflated');
  51.  
  52. {$IFDEF ShareWare}
  53.    PKMaxLen = 255;
  54.    CommentLen = 15;
  55. {$ELSE}
  56.    CommentLen = 65535;  { 64k max }
  57. {$EndIF}
  58.  
  59. TYPE
  60.  
  61.    FString      = String;
  62.    CharArray    = Array[1..PKMaxLen] of Char;
  63.  
  64.    CommentPtr   = ^CommentArray;
  65.    CommentArray = Array[1..1] of CHAR;
  66.  
  67.    FileStats = Record         { just to make storage size managable }
  68.      Name   : String[65];     { includes path                       }
  69.      OSize,                   { original size                       }
  70.      CSize,                   { compressed size                     }
  71.      Date,                    { date and time as longint            }
  72.      CRC    : Longint;        { Crc-32                              }
  73.      Attr   : LongInt;        { actually word TYPE in DOS           }
  74.      Method : Word;           { compression method                  }
  75.    end;
  76.  
  77.    ExtraData = Record
  78.      ExtraName: String[11];    { name of the data }  { proprietary }
  79.      ExtraID : Word;          { Id number of the data }
  80.      ExtraLen: Word;          { length of the data }
  81.      ExtraAddress: Longint;   { Offest of the data }
  82.     end;
  83.  
  84.    CentralFileHeaderType = Record
  85.       CentralSig   :LongInt;          { Central dir signature }
  86.       Madeby       : Word;            { HI = operating system, Lo Pkzip version }
  87.       VerReq       : Word;            { min PK version to extract }
  88.       GenPurp      : Word;            { Gen. purpose flag      }
  89.       Compresion   : Word;            { compersion method used }
  90.       lastFTime    : Word;            { Time of compression    }
  91.       lastFdate    : Word;            { Date of compression    }
  92.       crc32        : LongInt;         { magic number CRC32     }
  93.       Compsize     : LongInt;         { Compresed file size    }
  94.       UnCompSize   : LongInt;         { Original file size     }
  95.       NameLen      : Word;            { length of the name     }
  96.       Extralen     : Word;            { length of extra field  }
  97.       ComentLen    : Word;            { length of comment      }
  98.       DiskStart    : Word;            { # of disk which this file starts }
  99.       IntrenalAttr : Word;            { LO set indicates ASCII text, else binary file }
  100.       ExternalAttr : LongInt;         { HI is operating sys dependant, LO is DOS attr }
  101.       OffsetLocal  : LongInt;         { Offset from first disk of local header }
  102.       FileName     : FString;        { Storage of filename, nil if length zero }
  103.       Extra        : ExtraData;       { Storage of extra field, nil if len zero }
  104.       FileComment  : CharArray;         { Always nil, My choice. }
  105.      End;
  106.  
  107.      ZipEndRec = Record
  108.        EndSig      : LongInt;        { Signature of Directroy end           }
  109.        DiskNum     : Word;           { Number of this disk                  }
  110.        DiskwStart  : Word;           { # of disk with start of central dir  }
  111.        NumEntries  : Word;           { # of entries in central on this disk }
  112.        TNumEntries : Word;           { total number of entries, this central dir. }
  113.        SizeCentral : LongInt;        { Size of central directory            }
  114.        OffsetDirRelDiskNum: LongInt; { Offest of central dir in respect to
  115.                                        starting disk number                  }
  116.        CommentLen  :Word;            { zipfile comment length                }
  117.       end;
  118.  
  119. Function GetZipStats: Word;  { Call this first!!! }
  120. { Returns ...
  121.   0 : if ZipStats are usable.
  122.   1 : signature error, signature does not match may not be a zip file
  123.   2 : if Blockread failed.
  124.   IO error,  As reported by IOResult.
  125.  
  126.   =>  Basiclly Non zero if error occured, do not use ZIPStats.
  127. }
  128.  
  129. Procedure CFH_to_FileStat(VAR CFH: CentralFileHeadertype; VAR FS : FileStats);
  130. { Converts CentralFileHeaderType to FileStats type }
  131.  
  132. Function ReadFileHeader(VAR CFH: CentralfileHeadertype):Byte;
  133. {
  134.   Returns ...
  135.          0   no error, Cfh is OK.
  136.          1   Signiture is bad, do not use CFH.
  137.          2   disk read error, do not use CFH.
  138. }
  139.  
  140. Procedure ShowZipComment;
  141.  
  142. Procedure GetZipComment(VAR CPtr: CommentPtr; VAR Size:Word);
  143.  
  144. VAR
  145.    ZipStats       : ZipEndRec;     { Global zipstats }
  146.    ZipFile        :File;           { Zip filename.
  147.                                      NOTE: You open and assign and close it ! }
  148.    CentralAddress : LongInt;       { Offset of Central directory in file }
  149.                                    { Never change this! }
  150.  
  151. (**) IMPLEMENTATION (**)
  152.